package com.lilihub.miaosha.config;


import com.lilihub.miaosha.intercepter.AccessInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


import java.util.List;

/**
 * @BelongsProject: miaosha2
 * @BelongsPackage: com.lilihub.miaosha.config
 * @Author: LiYing
 * @CreateTime: 2021-04-26 16:34
 * @Description:
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {


    @Autowired
    private  UserArgumentResolver userArgumentResolver;

    @Autowired
    private AccessInterceptor accessInterceptor;


    //往controller中进行赋值参数
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {

        resolvers.add(userArgumentResolver);

    }

    //注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(accessInterceptor);
    }


}
